package top.ezzz.chats.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.noear.solon.annotation.*;
import top.ezzz.common.R;
import top.ezzz.chats.entity.GroupUser;
import top.ezzz.chats.service.IGroupUserService;
import top.ezzz.common.PageUtil;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author shenmk
 * @since 2024-01-08
 */
@Api("groupUser")
@Controller
@Mapping("/chats/groupUser")
public class GroupUserController {


    @Inject
    private IGroupUserService groupUserService;

    @ApiOperation("page")
    @Get
    @Mapping("page")
    public R page( GroupUser param) {
        Page<GroupUser> page = PageUtil.startPage();
        QueryWrapper<GroupUser> wrapper = new QueryWrapper<>(param);
        Page<GroupUser> groupPage = groupUserService.page(page, wrapper);
        return R.ok(groupPage);
    }

    @ApiOperation("get")
    @Get
    @Mapping("get")
    public R get(GroupUser param) {
        QueryWrapper<GroupUser> wrapper = new QueryWrapper<>(param);
        GroupUser result =  groupUserService.getOne(wrapper);
        return R.ok(result);
    }

    @ApiOperation("insert")
    @Post
    @Mapping("insert")
    public R insert(GroupUser param) {
        boolean result =  groupUserService.save(param);
        return R.ok(result);
    }

    @ApiOperation("update")
    @Put
    @Mapping("update")
    public R update(GroupUser param) {
        boolean result =  groupUserService.updateById(param);
        return R.ok(result);
    }

    @ApiOperation("delete")
    @Delete
    @Mapping("delete")
    public R delete(GroupUser param) {
        boolean result =  groupUserService.removeById(param);
        return R.ok(result);
    }

}
